<?php

class Functions {

    private $_ID;
    private $_name;
    private $_description;

    public function getID() {
        return $this->_ID;
    }

    public function setID($ID) {
        $this->_ID = $ID;
    }

    public function getName() {
        return $this->_name;
    }

    public function setName($name) {
        $this->_name = $name;
    }

    public function getDescription() {
        return $this->_description;
    }

    public function setDescription($description) {
        $this->_description = $description;
    }
    
    
    

    public function getByID($db = null) {

        if ($db != null) {

            $sql = 'SELECT
                        `F_ID`,
                        `F_Name`,
                        `F_Description`
                      FROM `functions`
                      WHERE F_ID = :F_ID';

            $parameters = array(':F_ID');
            $values = array($this->getID());
            $types = array(PDO::PARAM_INT);

            $result = $db->executeQuery($sql, $parameters, $values, $types);

            if ($result != null) {
                $row = $result->fetch();
                $this->setID($row->F_ID);
                $this->setName($row->F_Name);
                $this->setDescription($row->F_Description);
                return $this;
            } else {
                return null;
            }
        }
    }

}

?>
